﻿<div class="ph-tabs">
    <ul>
        <li class="k-state-active">学生成绩列表</li>
    </ul>
    <div>
        <div class="k-block divToolbar">
            <div style="display: inline-block;">
                <select id="selArchive" style="width: 300px"></select>
            </div>
            <div style="display: inline-block;">
                <select id="selClass"></select>
            </div>
            <span class="k-textbox k-space-right">
                <input type="text" placeholder="学生姓名或身份证" id="txtKey" />
                <a href="javascript:Filter()" class="k-icon k-i-search">&nbsp;</a>
            </span>
            <a class="k-button" onclick="Export()"><span class="k-icon k-i-calendar"></span><span>导出所有成绩明细</span></a>
        </div>
        <div id="grid_main" style="text-align: center"></div>

        <form id="exportForm" method="post" action="/Achievements/Mark/Export" target="_blank" style="display: none">
            <input type="hidden" name="archiveGuid" id="df_ArchiveGuid" />
            <input type="hidden" name="key" id="df_Key" />
        </form>
    </div>
</div>
<div id="wind"></div>
<script class="windows">
    var wnd = null;
</script>

<script class="init">
    var sGuid = "@PH.Web.Global.WebContext.CurrentSchool.Guid";
    LocatedMenu("体测数据", "学生成绩");

    $("#selArchive").kendoDropDownList({
        dataTextField: "Title",
        dataValueField: "Guid",
        dataSource: Whale.dataSource({
            url: "/Achievements/Archive/Gets",
            getParameters: function () {
                return {
                    aType: 2,
                    expired: false
                }
            }
        }),
        dataBound: function (e) {
            if (this.dataSource.data().length == 0) {
                this.setDataSource(new kendo.data.DataSource({
                    data: [{ Title: "暂无档案", Guid: "" }]
                }));
            }
        },
        change: function (e) { Filter(); }
    });

    $("#selClass").kendoDropDownList({
        optionLabel: {
            ID: 0,
            ClassName: "所有班级"
        },
        dataTextField: "ClassName",
        dataValueField: "ID",
        dataSource: Whale.dataSource({
            url: "/School/Class/GetClasses",
            getParameters: function () {
                return { schoolGuid: sGuid }
            }
        }),
        change: function (e) { Filter(); }
    });

    function Filter() {
        $("#grid_main").data("kendoGrid").dataSource.page(0);
    }

    function Export() {
        $("#df_ArchiveGuid").val($("#selArchive").data("kendoDropDownList").value());
        $("#exportForm").submit();
    }
</script>

<script class="grid_students_config">
    $(function () {
        var fields = [{
            title: "身份证",
            field: "StudentNo",
            width: 150
        }, {
            title: "姓名",
            field: "RealName",
            width: 100
        }, {
            title: "班级",
            field: "ClassName",
            width: 130
        }, {
            title: "性别",
            field: "Sex",
            template: "#=GetSexString(Sex)#",
            width: 60
        }, {
            title: "标准分",
            field: "StandardScore",
            width: 80
        }, {
            title: "附加分",
            field: "AdditionalScore",
            width: 80
        }, {
            title: "总分",
            field: "TotalScore",
            width: 80
        }, {
            title: "评级",
            field: "LevelScore",
            template: "#=ShowLevelScore(ScoreLevel)#",
            width: 60
        }, {
            title: "操作",
            template: "#=GetOperations(StudentGuid)#",
            attributes: { style: "text-align:left" },
            width: 100
        }, {}];

        $("#grid_main").kendoGrid({
            columns: fields,
            dataSource: Whale.dataSource({
                url: "/Analyses/ANS/GetS4Student",
                getParameters: function () {
                    var cid = $("#selClass").data("kendoDropDownList").value();
                    return {
                        aGuid: $("#selArchive").data("kendoDropDownList").value(),
                        sGuid: sGuid,
                        key: $("#txtKey").val(),
                        history: false,
                        classID: cid == "" ? 0 : cid
                    };
                },
                pageSize: 20
            }),
            pageable: {
                messages: {
                    empty: "暂无数据"
                }
            },
            dataBound: function (e) {
                //让表头居中
                $("th.k-header").attr("style", "text-align:center; font-weight:bold;");
            },
            sortable: true
        });
    });

    function GetOperations(guid) {
        var html = "<button class='k-button' onclick=\"Detail('" + guid + "')\"><span class='k-icon k-i-calendar '></span><span>详情</span></button>";
        return html;
    }

    function Detail(guid) {
        wnd = $("#wind").kendoWindow({
            title: "学生成绩详情",
            visible: false,
            modal: true,
            resizable: false,
            width: 600,
            content: {
                url: "/Achievements/Mark/DetailByStudent/" + guid
            },
            open: function () { this.center(); }
        }).data("kendoWindow");
        wnd.open();
    }
</script>
